package com.retail.order.controller;

import com.retail.core.common.AbstractCommonController;
import com.retail.core.entity.ParamReq;

import com.retail.core.entity.result.PageResult;
import com.retail.core.entity.result.Result;
import com.retail.global.security.LoginUserUtil;
import com.retail.global.annon.TraceLog;
import com.retail.order.entity.request.AdminVerifyDetailOrderRequest;
import com.retail.order.entity.vo.AdminVerifyDetailOrderVo;
import com.retail.order.service.AdminVerifyDetailOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* 订单核销明细 API
* @author Administrator
*/
@Api(tags = "订单核销明细 API")
@RestController
@RequestMapping("/adminVerifyDetailOrder")
public class AdminVerifyDetailOrderController extends AbstractCommonController<AdminVerifyDetailOrderService, AdminVerifyDetailOrderRequest, AdminVerifyDetailOrderVo> {

    private final AdminVerifyDetailOrderService adminVerifyDetailOrderService;

    public AdminVerifyDetailOrderController(AdminVerifyDetailOrderService adminVerifyDetailOrderService) {
        this.adminVerifyDetailOrderService = adminVerifyDetailOrderService;
    }

    @TraceLog()
    @GetMapping("{id}")
    public Result<AdminVerifyDetailOrderVo> getModel(@PathVariable("id") Long id) {
        return super.getModel(adminVerifyDetailOrderService, id);
    }

    @TraceLog()
    @PostMapping
    @ApiOperation("保存订单核销明细")
    public Result<Integer> save(@RequestBody AdminVerifyDetailOrderRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.save(adminVerifyDetailOrderService, request);
    }

    @TraceLog()
    @PutMapping
    @ApiOperation("更新订单核销明细")
    public Result<Integer> update(@RequestBody AdminVerifyDetailOrderRequest request) {
        request.setCreateUser(LoginUserUtil.getUserId());
        return super.update(adminVerifyDetailOrderService, request);
    }

    @TraceLog()
    @PostMapping("listPage")
    @ApiOperation("订单核销明细-查询")
    public Result<List<AdminVerifyDetailOrderVo>>listPage(@RequestBody ParamReq<AdminVerifyDetailOrderRequest> req) {
        return super.listPage(adminVerifyDetailOrderService, req);
    }

    @TraceLog()
    @PostMapping("countPage")
    @ApiOperation("订单核销明细-统计")
    public Result<Integer> countPage(@RequestBody ParamReq<AdminVerifyDetailOrderRequest> req) {
        return super.countPage(adminVerifyDetailOrderService, req);
    }

    @TraceLog()
    @PostMapping("page")
    @ApiOperation("订单核销明细-分页数据")
    public Result<PageResult> page(@RequestBody ParamReq<AdminVerifyDetailOrderRequest> req) {
        return super.page(adminVerifyDetailOrderService, req);
    }

    @TraceLog()
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除订单核销明细")
    public Result<Integer> delete(@PathVariable("id") Long id) {
        return super.delete(adminVerifyDetailOrderService, id);
    }

    @TraceLog()
    @ApiOperation("批量删除订单核销明细")
    @DeleteMapping("{ids}")
    public Result<Integer> batchDelete(@PathVariable("ids") List<Long> ids) {
        return super.batchDelete(adminVerifyDetailOrderService, ids);
    }

    @Override
    public Long getLoginUserId() {
        return LoginUserUtil.getUserId();
    }

}
